package com.ylbh.modules.rechargeablecard.controller;

import com.ylbh.common.annotation.SysLog;
import com.ylbh.common.pojo.rechargeablecard.dto.CardListDTO;
import com.ylbh.common.utils.CommonResult;
import com.ylbh.common.utils.PageUtils;
import com.ylbh.common.utils.Ref;
import com.ylbh.modules.rechargeablecard.service.RechargeableCardService;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * 充值卡
 * @author czx
 * @date 2019-05-09 19:25:02
 */
@RestController
@RequestMapping("card")
public class RechargeableCardController {

    @Autowired
    private RechargeableCardService rechargeableCardService;

    @ApiOperation("充值卡列表")
    @RequestMapping("queryCardList")
    @RequiresPermissions("card:queryCardList")
    public CommonResult<PageUtils> queryCardList(CardListDTO cardListDTO) {
        PageUtils list = rechargeableCardService.queryCardList(cardListDTO);
        return Ref.ok(list);
    }

    @SysLog("充值卡状态修改")
    @ApiOperation("充值卡状态修改")
    @PostMapping("modifyRechargeableCardStatusById/{type}")
    @RequiresPermissions("card:modifyRechargeableCardStatusById")
    public CommonResult modifyRechargeableCardStatusById(@RequestBody String[] id, @PathVariable String type) {
        rechargeableCardService.modifyRechargeableCardStatusById(Arrays.asList(id), type);
        return Ref.ok();
    }

}
